<?php
    /*
        @desc app base class to handle view and db functions
    */
    class PageBase
    {
        /*
            @access protected
            @var resource
        */
        protected $db;

        /*
            @desc init all the system feature
            @access public
        */
        public function __construct( ){
            $this->_initDb( );
            $this->_initView( );
        }


        /*
            @desc init the system framework page class db handling part
            @access private
            @return void
        */
        final private function _initDb( ){
            $this->db = getDb( );
        }

        /*
            @desc init the system framework page class view handling part
            @access private
            @return void
        */
        final private function _initView(){
            
        }
        
        /*
            @desc load view of specified template file and init a quickskin object for rendering
            @access protected
            @param string tpl the template filename of current page rendering
            @param array? data the template vars defined in the framework
            @return object quickskin object containing the template parsing object
        */
        final protected function view($tpl, $ext = '.tpl'){
            $tpl = $tpl . $ext;
            return new QuickSkin( $tpl );
        }

        /*
            @desc load a system lib directory library and init the setting for the lib
            @access protected
            @param string libName the library name of the loading
            @return bool successful state
        */
        final protected function lib($libName){
            return load_lib( $libName );
        }
        
        /*
            @desc load a system application as another application's model
            @access protected
            @param string appName the application name of the loading progress
            @return object instance of the application model
        */
        final protected function app($appName){
        	return load_app( $appName );
        }

    }